<?php

namespace App\Http\Controllers\WAP\User;

use Illuminate\Http\Request;
use Session,Config;
use App\Http\Requests;
use App\Http\Service\User\UserService;
use App\Http\Controllers\Controller;

class LogoutController extends Controller
{

    public function logout()
    {
        $where = [];
        $token = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));
        $where['token'] = $token;

        $user = new UserService();

        $ret = $user->logout($where);
        if($ret['code'] == 0)
        {
            Session::forget(Config::get('custom.setting.MEMBER_TOKEN'));
            Session::forget(Config::get('custom.setting.MEMBER_VIP_FLAG'));
            Session::forget(Config::get('custom.setting.MEMBER_INFO'));
        }

        return redirect('/');
    }
}
